{% extends 'generic/object_detail.html' %}
{% load helpers %}

{% block extra_buttons %}
        {% if perms.extras.change_gitrepository %}
            <form class="form-inline" style="display: inline-block"
                  method="post" action="{% url 'extras:gitrepository_sync' slug=object.slug %}">
                {% csrf_token %}
                <button type="submit" class="btn btn-primary">
                    <i class="mdi mdi-source-branch-sync" aria-hidden="true"></i> Sync
                </button>
            </form>
        {% endif %}
{% endblock extra_buttons %}

{% block nav_tabs %}
        <li role="presentation"{% if not active_tab %} class="active"{% endif %}>
            <a href="{{ object.get_absolute_url }}">Git Repository</a>
        </li>
        <li role="presentation"{% if active_tab == 'result' %} class="active"{% endif %}>
             <a href="{% url 'extras:gitrepository_result' slug=object.slug %}">Synchronization Status</a>
        </li>
        {% if perms.extras.view_objectchange %}
            <li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
                <a href="{% url 'extras:gitrepository_changelog' slug=object.slug %}">Change Log</a>
            </li>
        {% endif %}
{% endblock nav_tabs %}

{% block content_left_page %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Repository Details</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <tr>
                        <td>Remote URL</td>
                        <td>{{ object.remote_url }}</td>
                    </tr>
                    <tr>
                        <td>Branch</td>
                        <td>
                            <code>{{ object.branch }}</code>
                            {% if object.current_head %}
                                (checked out locally at commit <code>{{ object.current_head }}</code>)
                            {% else %}
                                (not locally checked out yet)
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Username <em>(deprecated)</em></td>
                        <td>{{ object.username | placeholder }}</td>
                    <tr>
                    <tr>
                        <td>Token <em>(deprecated)</em></td>
                        <td>{{ object.token_rendered }}</td>
                    </tr>
                    <tr>
                        <td>Secrets Group</td>
                        <td>
                            {% if object.secrets_group %}
                                <a href="{{ object.secrets_group.get_absolute_url }}">{{ object.secrets_group }}</a>
                            {% else %}
                                <span class="text-muted">&mdash;</span>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
{% endblock content_left_page %}

{% block content_right_page %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Provided Data Types</strong>
                </div>
                <table class="table table-hover panel-body">
                    {% for entry in datasource_contents %}
                        <tr>
                            <td>
                                <span style="display: inline-block" class="label label-info">
                                    <i class="mdi {{ entry.icon }}"></i>
                                </span>
                                {{ entry.name|title }}</td>
                            <td>
                                {% if entry.content_identifier in object.provided_contents %}
                                    <span class="text-success"><i class="mdi mdi-check-bold"></i></span>
                                {% else %}
                                    <span class="text-danger"><i class="mdi mdi-close"></i></span>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </table>
            </div>
{% endblock %}
